package com.itheima03;

import java.io.*;
import java.util.ArrayList;
import java.util.Properties;

public class Work07 {
    public static void main(String[] args) throws IOException {
        ArrayList<String> list = new ArrayList<>();
        BufferedReader br = new BufferedReader(new FileReader("maths.txt"));
        String line;
        while ((line = br.readLine()) != null) {
            String o = "";
            if (line.contains("+")) {
                o = "+";
            }
            if (line.contains("-")) {
                o = "-";
            }
            if (line.contains("*")) {
                o = "*";
            }
            if (line.contains("/")) {
                o = "/";
            }
            int index = line.indexOf(o);
            int num1 = Integer.parseInt(line.substring(0, index));
            int num2 = Integer.parseInt(line.substring((index + 1)));
            int heima = 0;
            switch (o) {
                case "+":
                    heima = num1 + num2;
                    break;
                case "*":
                    heima = num1 * num2;
                    break;
                case "-":
                    heima = num1 - num2;
                    break;
                case "/":
                    heima = num1 / num2;
                    break;
            }
            list.add(num1 + o + num2 + "=" + heima);


        }
        br.close();

        BufferedWriter bw = new BufferedWriter(new FileWriter("maths.txt"));

        list.forEach(s -> {
            try {
                bw.write(s);
                bw.newLine();
            } catch (IOException e) {

            }

        });
        bw.close();
    }
}
